package com.superbytecode.stencil.strategy;

import cn.hutool.core.map.MapUtil;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * All rights Reserved, Designed By www.super-master.com
 *
 * @ProjectName: magician
 * @Package: com.superbytecode.magician.core.strategy
 * @ClassName: SQLStrategyEnum
 * @Description: []
 * <p> </p>
 * @Author: [Lance Ting]
 * @Date: 2024/10/10 11:19
 * @Version: V1.0
 * @Copyright: 2024 www.super-master.cn Inc. All rights reserved.
 * TODO: 注意,本文件Lance Ting所作,如果转载或使用请标明具体出处!
 **/
@Getter
public enum SQLStrategyEnum {
    MYSQL("mysql", "mysql"),//
    ORACLE("oracle", "oracle"),//
    POSTGRESQL("postgresql", "postgresql"),//
    SQLSERVER("sqlserver", "sqlserver"),//
    ;
    // -----------------------------------------------------------------------------------------------------------------

    // 初始化sql策略
    public final static Map<String, SQLScriptStrategy> sqlScriptStrategyMap = new HashMap<>();

    public static SQLScriptStrategy ofScriptStrategy(String code) {
        return MapUtil.get(sqlScriptStrategyMap, code, SQLScriptStrategy.class);
    }

    // 初始化sql类型策略
    public final static Map<String, SQLTypeStrategy> sqlTypeStrategyMap = new HashMap<>();

    public static SQLTypeStrategy ofTypeStrategy(String code) {
        return MapUtil.get(sqlScriptStrategyMap, code, SQLTypeStrategy.class);
    }

    // -----------------------------------------------------------------------------------------------------------------
    /**
     * 策略编码 {@link }
     */
    final private String code;
    /**
     * 策略描述
     */
    final private String name;

    SQLStrategyEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }
}